package com.springboot.user.service;

import com.springboot.user.mapper.UserMapper;
import com.springboot.user.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Random;

/**
 * @author XiaoLuo
 * @ClassName: UserService
 * @Description: ${todo}
 * @date 2019/4/6 20:53
 */
@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    public User queryById(Long id) throws InterruptedException {
        // 为了演示超时现象，我们在这里然线程休眠,时间随机 0~2000毫秒
//        Thread.sleep(new Random().nextInt(2000));

        return this.userMapper.selectByPrimaryKey(id);
    }
}
